package com.ebt.m.activity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.ebt.m.AppContext;
import com.ebt.m.R;
import com.ebt.m.data.bean.CardInfo;
import com.ebt.m.commons.utils.ToastUtil;
import com.ebt.m.view.CircleImageView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 用户绑定信息显示页面
 * 如果用户的 phone 不为空，则显示 phone；为空，则网络获取 UserInfo 中的 phone
 */
public class CancelAuthConfirmActivity extends BaseToolBarActivity {


    @BindView(R.id.user_avatar)
    CircleImageView userAvatar;
    @BindView(R.id.user_name)
    TextView userName;
    @BindView(R.id.user_employee)
    TextView userEmployee;
    @BindView(R.id.desc)
    TextView desc;
    @BindView(R.id.employee_container)
    LinearLayout employeeContainer;
    @BindView(R.id.tv_phone)
    TextView tvPhone;
    @BindView(R.id.action_cancel)
    Button actionCancel;
    @BindView(R.id.user_company)
    TextView userCompany;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cancel_auth_confirm);
        ButterKnife.bind(this);
        setTitle("取消认证");
    }

    @Override
    protected void init() {
        super.init();
        initViews();
    }

    public void initViews() {
        CardInfo cardInfo = AppContext.getCurrentUser().getCardInfo();
        if (cardInfo != null) {
            userName.setText(cardInfo.getName());
            userCompany.setText(cardInfo.getCompanyName());
            userEmployee.setText(cardInfo.getEmployeeNo());
            tvPhone.setText(cardInfo.getPhone());
            Glide.with(this)
                    .load(AppContext.getCurrentUser().getCardInfo().getImgUrl())
                    .error(R.drawable.empty_photo)
                    .dontAnimate()
                    .into(userAvatar);
        } else {
            ToastUtil.show(this, "个人资料为空");
        }
        desc.setText("取消认证后," + getResources().getString(R.string.app_name) + "将退出登录");
    }

    @OnClick(R.id.action_cancel)
    public void onViewClicked() {
        Intent intent = new Intent(this, CancelAuthenticationActivity.class);
        startActivity(intent);
    }
}
